/*
 * Copyright 2013-2019 Xia Jun(3979434@qq.com).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 ***************************************************************************************
 *                                                                                     *
 *                        Website : http://www.farsunset.com                           *
 *                                                                                     *
 ***************************************************************************************
 */
package xin.alum.aim.groups;


import io.netty.channel.ChannelId;
import lombok.Data;
import xin.alum.aim.constant.AimPlatform;
import xin.alum.aim.util.JSONUtils;

import java.io.Serializable;

@Data
public class Session implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 用户id
     */
    private String uid;
    /**
     * 新的连接通道id
     */
    private String cid;
    /**
     * 登录平台
     */
    private AimPlatform platform;

    /**
     * 客户ip
     */
    private String clientIp;

    /**
     * 客户设备信息id
     */
    private String deviceId;

    public Session() {
    }

    public Session(String uid, ChannelId cid, AimPlatform platform, String clientIp, String deviceId) {
        this.uid = uid;
        this.cid = cid.asShortText();
        this.platform = platform;
        this.clientIp = clientIp;
        this.deviceId = deviceId;
    }

    @Override
    public String toString() {
        return JSONUtils.toJSONString(this);
    }
}
